package net.ddns.xcyyds.kungfu.procedures;

import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;

import java.util.Random;

public class OneHandJian2Procedure {
	public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
		if (entity == null)
			return;
		{
			ItemStack _ist = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
			if (_ist.hurt(1, new Random(), null)) {
				_ist.shrink(1);
				_ist.setDamageValue(0);
			}
		}
		if ((entity.getPersistentData().getString("NO3")).equals("R") || (entity.getPersistentData().getString("NO3")).equals("L")) {
			OneHandJian3Procedure.execute(entity);
		} else {
			if ((entity.getPersistentData().getString("NO1")).equals("L") && (entity.getPersistentData().getString("NO2")).equals("L")) {
				LLProcedure.execute(world, x, y, z, entity);
			}
			if ((entity.getPersistentData().getString("NO1")).equals("R") && (entity.getPersistentData().getString("NO2")).equals("R")) {
				RRProcedure.execute(world, x, y, z, entity);
			}
			if ((entity.getPersistentData().getString("NO1")).equals("L") && (entity.getPersistentData().getString("NO2")).equals("R")) {
				LRProcedure.execute(world, x, y, z, entity);
			}
			if ((entity.getPersistentData().getString("NO1")).equals("R") && (entity.getPersistentData().getString("NO2")).equals("L")) {
				RLProcedure.execute(world, x, y, z, entity);
			}
		}
	}
}
